import React from 'react';
// import Client from './Client';
import {
  DropdownButton,
  Dropdown,
} from 'react-bootstrap';
export default function UsrDrop(props){
  let state,setState;
  [state,setState]=React.useState({
    selected:""
  });
  const onSelect=(eventKey,event)=>{
    let user_name=event.target.innerText;
    setState({selected:user_name}); 
    props.onSelect(user_name);
  }
    const userMenu = props.users.map((user, idx) => (
      <Dropdown.Item  key={idx}>
        {user.username}
      </Dropdown.Item>
    ));
    return (
      <DropdownButton
        variant="light"
        title={props.title?props.title+":"+state.selected:""}
        onSelect={onSelect}
      >
        <Dropdown.Item>
          *
        </Dropdown.Item>
        {
          userMenu
        }
      </DropdownButton>
    );
};

